  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
		<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<script src="../public/lobster/js/public.js"></script>
		<link rel="stylesheet" type="text/css" href="../public/lobster/icon/iconfont.css">
		<link rel="stylesheet" href="../public/lobster/css/public.css">
		<link rel="stylesheet" href="../public/lobster/css/shared.css">
		<link rel="stylesheet" href="../public/lobster/css/href.css?20170421">
		<title>实名认证</title>
	     <style>
	    .nav{
	    padding-bottom: 0.06rem !important;
	     bottom:0 !important;
	         height: 1.02rem !important;
	     </style>
	</head>
	<body class='real'>
	
	
	
		<div class="realname">
			<div class="inputdata">
				<div>
					<span>用户名：</span>
					<input type="text" placeholder="请输入注册的用户名" value="A1111139059" id="username" readonly="readonly">
				</div>
				<p  class="tips" id="op_uname"></p>
				<div>
					<span>真实姓名：</span>
					<input type="text" placeholder="请输入您的真实姓名" id="name">
				</div>
				<p  class="tips" id="op_name"></p>
				<div>
					<span>性别：</span>
					<input type="radio" name="inst" id="man" value="1" class="sel_man" checked />男
					<input type="radio" name="inst" id="wom" value="2" class="sel_wom">女
				</div>
				<div>
					<span>手机：</span>
					
					<input type="text" placeholder="请输入您的手机号" id="phone" value="13268132797" readonly="readonly">
					
					
				
				</div>
				<p  class="tips " id="op_phone"></p>
				<div>
				<span>验证码：</span> <input type="text" placeholder="请输入手机验证码"
					id="msgcode">
				<a  href="#" class="get" id="getSmscode" name="getSmscode" onclick="getToken()">获取验证码</a>	
				</div>
				
				<div style="display:none">
					<span>所属机构： </span>
					<input type='hidden' value="2873" id="orgId">
					<input type="text" placeholder="请输入机构编码"  value="默认加盟商" readonly="readonly" >
				</div>
				<p  class="tips " id="op_orgId"></p>
				<div>
					<span>身份证：</span>
					<input type="text" placeholder="请输入您的身份证号码" id="idcard">
				</div>
				<p  class="tips " id="op_idcard"></p>
			</div>
	
			<h1>请保证您输入的信息与微信实名绑定的姓名、身份证号信息一致，否则将有可能会影响您的退货申请</h1>
		</div>
		<div class="okup">
			<button class="success"  onclick="success()" >提 交 审 核</button>
		</div>
	
	
	
	

		
       
       <!--底部导航栏-->
 		<nav class="nav">
			<ul id="list">
				<li>
					<a href="index.html">
						<img src="../public/lobster/images/navbar01.png" alt="">
					</a>
				</li>
				<li>
					<a href="lotteryInfo.html">
						<img src="../public/lobster/images/navbar02.png" alt="">
					</a>
				</li>
				<li>
					<a href="center.html">
						<img src="../public/lobster/images/onnavbar03.png" alt="">
					</a>
				</li>
			</ul>
		</nav>
	</body>
	<script src="../public/lobster/js/jq-2.1.0.js"></script>
	<script>
			function setImagePreviews(dv,inp) {
				var docObj = document.getElementById(inp);
				var dd = document.getElementById(dv);
				dd.innerHTML = "";
					dd.innerHTML += "<div style='width: 3rem' class='bt'> <img id='img" + dv + "'  /> </div>";
					var imgObjPreview = document.getElementById("img"+dv);
					if (docObj.files && docObj.files[0]) {
						//火狐下，直接设img属性
						imgObjPreview.style.display = 'block';
						imgObjPreview.style.width = '4.6rem';
						imgObjPreview.style.height = '2.6rem';
						//imgObjPreview.src = docObj.files[0].getAsDataURL();
						//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
						imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
					}
					else {
						//IE下，使用滤镜
						docObj.select();
						var imgSrc = document.selection.createRange().text;
						//alert(imgSrc)
						//xxone.popup("提示",imgSrc,"确认");
						var localImagId = document.getElementById("img" + dv);
						//必须设置初始大小
						localImagId.style.width = "4.6rem";
						localImagId.style.height = "2.6rem";
						//图片异常的捕捉，防止用户修改后缀来伪造图片
						try {
							localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
							localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
						}
						catch (e) {
							//alert("您上传的图片格式不正确，请重新选择!");
							xxone.popup("提示","您上传的图片格式不正确，请重新选择!","确认");
							return false;
						}
						imgObjPreview.style.display = 'none';
						document.selection.empty();
					}
				return true;
			}
			
			function id(a){
				return document.getElementById(a);
			}
			function success(){
				//var reg=/^1[35789][0-9]{9}$/;
				var reg=/^0?1[3|4|5|7|8][0-9]\d{8}$/;
				var reg1=/^[0-9]{17}[0-9a-zA-Z]$/;
				var username=id('username').value;
				var name=id('name').value;
				var phone=id('phone').value;
				var idcard=id('idcard').value;
				var msgcode= $("#msgcode").val();
				var orgCode=$("#orgId").val();
				function funll(a,b){
					window.parent.scroll(0,0);
					id(a).style.height='1.5em';
					id(a).innerHTML=b;
				}
				var tips=document.getElementsByClassName('tips');
				var tips_list=tips.length;
				while(tips_list--){
					tips[tips_list].style.height='0px';
					tips[tips_list].innerHTML='';
				}
				switch(''){
					case username:
						//funll('op_uname','用户名不能为空');
						xxone.popup("提示","用户名不能为空","确认");
						return;
					case name:
						//funll('op_name','姓名不能为空')
						xxone.popup("提示","姓名不能为空","确认");
						return;
					case phone:
						//funll('op_phone','手机号码不能为空');
						xxone.popup("提示","手机号码不能为空","确认");
						return;
					case idcard:
						//funll('op_idcard','身份证号不能为空');
						xxone.popup("提示","身份证号不能为空","确认");
						return;
				}
				if(orgCode==null||orgCode==""){
					//funll("op_orgId","机构码不能为空");
					xxone.popup("提示","机构码不能为空","确认");
					return;
				}
				if(username==null||username.replace(/(^\s*)|(\s*$)/g, "").length<1){
					//funll("op_orgId","机构码不能为空");
					xxone.popup("提示","用户名不能为空","确认");
					return;
				}
				if (!reg.test(phone)){
					//funll('op_phone','手机号格式错误');
					xxone.popup("提示","手机号格式错误","确认");
					return;
				}
				if (!reg1.test(idcard)){
					//funll('op_idcard','身份证号码格式有误');
					xxone.popup("提示","身份证号码格式有误","确认");
					return;
				}
				//取性别
				var sex;
				var docs = document.getElementsByName("inst");
				for(var i=0;i<docs.length;i++){
					if(docs[i].checked==true){
						sex=docs[i].value;
						break;
					}
				}
				if(msgcode==null||msgcode==""){
					//alert("验证码不能为空");
					xxone.popup("提示","验证码不能为空","确认");
					return;
				}
				$.ajax({
					url:"/self/edit",
					type:"POST",
					data:{
						"sex":sex,
						"phone":phone,
						"loginname":username,
						"uname":name,
						"idcard":idcard,
						"msgcode":msgcode,
						"orgCode":orgCode
					},
					dataType:"json",
					success:function(data){
						
						if(data.success){
							//alert("信息已提交，正在审核中");
							xxone.popup("提示","信息已提交，正在审核中","确认");
							$('#xxone-popup-done').bind('click',function(){
									window.location.reload();
		    				  });
						}else{
							//alert(data.msg);
							xxone.popup("提示",data.msg,"确认");
							$('#xxone-popup-done').bind('click',function(){
								window.location.reload();
	    				  });
						}
					}
				})
				
			};
			
		//验证码倒计时一分钟  @zzb
			var wait = 60;
		    function countTime() {

		        if (wait == 0) { 
		        	$("#getSmscode").attr("disabled",false);
		        	$("#getSmscode").text("获取验证码"); 
		          	wait = 60; 
		        } else { 
		        	$("#getSmscode").attr("disabled",true); 
		        	$("#getSmscode").text(wait+"秒后可再发送"); 
		          wait--; 
		          setTimeout(function() { 
		        	  countTime();
		          }, 
		          1000) 
		        } 
		      } 	
			
			
			
	 function getToken(){
		 //var reg=/^1[35789][0-9]{9}$/;
		 var reg = /^0?1[3|4|5|7|8][0-9]\d{8}$/;
		 var phone = $("#phone").val();
		 /* if(!reg.test(phone)){
			 //alert("手机号码格式错误");
			 xxone.popup("提示","手机号码格式错误","确认");
			 return ;
		 } */
	 if(!reg.test(phone))
		{
			
			$("#cDiv").html("<font color='red' size='4px'>手机号码格式错误!</font>");
			return;
		}
		// alert(1);
	  if(wait!=60){
 		return;
 	}
		
		 $.ajax({
			url:"/user/getToken",
			type:"POST",
			data:{"phone":phone},
			dataType:"json",
			success:function(data){
				if(data.success){
					
					countTime();
					//alert(data.msg);
					xxone.popup("提示",data.msg,"确认");
				}else{
					//alert(data.msg);
					xxone.popup("提示",data.msg,"确认");
					$('#xxone-popup-done').bind('click',function(){
						window.location.reload();
				  });
				}
			}
			 
		 });
		 
		 
	 }
		</script>
</html>
